package com.lsq.baseadmin.modules.setting.controller;

import com.lsq.baseadmin.modules.setting.entity.SystemSetting;
import com.lsq.baseadmin.modules.setting.service.SystemSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 系统设置 前端控制器
 * </p>
 *
 * @author lsq
 * @since 2020-11-26
 */
@Api("系统设置")
@RestController
@RequestMapping("/systemSetting")
public class SystemSettingController {

    @Autowired
    public SystemSettingService systemSettingService;


     /**
     * 查询
     * @return ResponseEntity
     */
    @ApiOperation("系统设置查询")
    @GetMapping("/get")
    public ResponseEntity get() {
        List<SystemSetting> list = systemSettingService.list();
        if (list.isEmpty()) {
            return new ResponseEntity(HttpStatus.OK);
        }
        return ResponseEntity.ok(list.get(0));
    }

     /**
     * 修改
     * @param entity SystemSetting
     * @return ResponseEntity
     */
    @ApiOperation("系统设置修改")
    @PostMapping("/update")
    public ResponseEntity update(@RequestBody SystemSetting entity) {
        systemSettingService.saveOrUpdate(entity);
        return new ResponseEntity(HttpStatus.OK);
    }


}
